// This file was decompiled using SASCM.ini published on 2021-07-05
{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "copscar" 

// By ArtemQa146

const
    Bit_sets = 5@
    Police_Man = 4@
    Violation_Type = 12@
    Police_Car = 6@
    Speed_Limit = 1
    Car_Collided = 2
    Object_Collided = 3
    Stopped_car = 4
    Actor_pay = 5
    Pressed_Key_Step = 6
    Actor_pay_step_2 = 7
    Actor_pay_step_3 = 8
    Back_to_car = 9
    
    Check_Actor = 6
    Check_Car= 7
    Check_Player_Car = 8
    
    Time_Limit = 300
    Time_Message = 200
    
    Text_font_0 = 10
    Text_font_1 = 11
    Text_font_2 = 12
    Text_font_3 = 13
    Text_Size_1 = 14
    Text_Size_2 = 15
    Text_Size_3 = 16
    Text_Size_4 = 17
end

//  
08C3: clear Bit_sets bit 1
08C3: clear Bit_sets bit 2
08C3: clear Bit_sets bit 3
08C3: clear Bit_sets bit 4
08C3: clear Bit_sets bit 5
08C3: clear Bit_sets bit Check_Actor
08C3: clear Bit_sets bit Check_Car

0AF0: 0@ = get_int_from_ini_file "CLEO\copscar.ini" section "General Settings" key "Car collided"
if 0@ == 1
then 08BD: set Bit_sets bit 1 
end
0AF0: 0@ = get_int_from_ini_file "CLEO\copscar.ini" section "General Settings" key "Object collided"
if 0@ == 1
then 08BD: set Bit_sets bit 2
end
0AF0: 0@ = get_int_from_ini_file "CLEO\copscar.ini" section "General Settings" key "Ped Cops Reaction"
if 0@ == 1
then 08BD: set Bit_sets bit 3
end
0AF0: 0@ = get_int_from_ini_file "CLEO\copscar.ini" section "General Settings" key "Easy mode"
if 0@ == 1
then 08BD: set Bit_sets bit 4
end
0AF0: 0@ = get_int_from_ini_file "CLEO\copscar.ini" section "General Settings" key "Escape Mode"
if 0@ == 1
then 08BD: set Bit_sets bit 5
end

//   
0AF2: 8@ = get_float_from_ini_file "cleo\copscar.ini" section "Speed Settings" key "Speed Limit City"
0AF2: 26@ = get_float_from_ini_file "cleo\copscar.ini" section "Speed Settings" key "Speed Limit Countryside"
0AF2: 23@ = get_float_from_ini_file "cleo\copscar.ini" section "Speed Settings" key "Speed limit Night"

//   
0AF0: 11@ = get_int_from_ini_file "CLEO\copscar.ini" section "General Settings" key "Escape Max"
11@ += 1
0085: 27@ = 11@ // (int)

//  UI
0AF2: 13@ = get_float_from_ini_file "cleo\copscar.ini" section "Visual Settings" key "Icon Position X"
0AF2: 14@ = get_float_from_ini_file "cleo\copscar.ini" section "Visual Settings" key "Icon Position Y"
0AF2: 21@ = get_float_from_ini_file "cleo\copscar.ini" section "Visual Settings" key "Icon Scale X"
0AF2: 22@ = get_float_from_ini_file "cleo\copscar.ini" section "Visual Settings" key "Icon Scale Y"
0AF2: 29@ = get_float_from_ini_file "cleo\copscar.ini" section "Visual Settings" key "Money Position X"
0AF2: 30@ = get_float_from_ini_file "cleo\copscar.ini" section "Visual Settings" key "Money Position Y"

// 
08C3: clear Bit_sets bit Text_font_0
08C3: clear Bit_sets bit Text_font_1
08C3: clear Bit_sets bit Text_font_2
08C3: clear Bit_sets bit Text_font_3

0AF0: 0@ = get_int_from_ini_file "CLEO\copscar.ini" section "Visual Settings" key "Text Font"
if 0@ == 0
then 08BD: set Bit_sets bit Text_font_0
end
if 0@ == 1
then 08BD: set Bit_sets bit Text_font_1
end
if 0@ == 2
then 08BD: set Bit_sets bit Text_font_2
end
if 0@ == 3
then 08BD: set Bit_sets bit Text_font_3
end

//  
08C3: clear Bit_sets bit Text_Size_1
08C3: clear Bit_sets bit Text_Size_2
08C3: clear Bit_sets bit Text_Size_3
08C3: clear Bit_sets bit Text_Size_4

0AF0: 0@ = get_int_from_ini_file "CLEO\copscar.ini" section "Visual Settings" key "Text Size"
if 0@ == 1
then 08BD: set Bit_sets bit Text_Size_1
end
if 0@ == 2
then 08BD: set Bit_sets bit Text_Size_2
end
if 0@ == 3
then 08BD: set Bit_sets bit Text_Size_3
end
if 0@ == 4
then 08BD: set Bit_sets bit Text_Size_4
end

//    
0AF0: 20@ = get_int_from_ini_file "CLEO\copscar.ini" section "money" key "Speed Limit"
0AF0: 24@ = get_int_from_ini_file "CLEO\copscar.ini" section "money" key "Car collided"
0AF0: 28@ = get_int_from_ini_file "CLEO\copscar.ini" section "money" key "Object collided"
0AF0: 31@ = get_int_from_ini_file "CLEO\copscar.ini" section "money" key "Adding the amount"

//  
0AF0: 19@ = get_int_from_ini_file "CLEO\copscar.ini" section "Key Settings" key "Gamepad Key"
0AF0: 17@ = get_int_from_ini_file "CLEO\copscar.ini" section "Key Settings" key "key"


while true
wait 0 
if
   Player.Defined($PLAYER_CHAR) 
then
    // ds:_ZN6CCheat15m_aCheatsActiveE.IDoAsIPlease ; CCheat::m_aCheatsActive
    0A8D: 1@ = read_memory 0x969171 size 4 virtual_protect 0
    if
        1@ == 0 //   . 1 - never wanted
    then
        if and
            $ONMISSION == 0
            Actor.Driving($PLAYER_ACTOR)
            810F:   not player $PLAYER_CHAR wanted_level > 0
        then
            if
                08B7:   test Bit_sets bit 3 //   
            then
                1@ = 1 //      
            else
                1@ = 0 //     
            end
    if
        0EA5: get_closest_cop_near_char $PLAYER_ACTOR radius 40.0 alive 1 in_car 1 on_foot 1@ seen_in_front 1 store_to Police_Man
    then
        0@ = Actor.CurrentCar($PLAYER_ACTOR)
        046C: 1@ = car 0@ driver
        if
            003B:   1@ == $PLAYER_ACTOR  //    
        then
            0E12: get_vehicle 0@ subclass_to 1@
            if or
                1@ == 9 // 
                1@ == 0 // 
                1@ == 2 // 
            then
            Violation_Type = 0
            
            0E40: get_current_hour 1@
                //  
                if and
                    1@ >= 6
                    1@ <= 21
                then
                    0842: 1@ = player $PLAYER_CHAR town_number
                    //   
                    if or
                        1@ == 1
                        1@ == 2
                        1@ == 3
                    then
                        02E3: 1@ = car 0@ speed
                        if
                            0035:   1@ >= 8@  // (float)
                        then
                            Violation_Type = Speed_Limit
                            0085: 25@ = 20@ //   
                        end
                    else
                    //    
                        02E3: 1@ = car 0@ speed
                        if
                            0035:   1@ >= 26@  // (float)
                        then
                            Violation_Type = Speed_Limit
                            0085: 25@ = 20@ //   
                        end
                    end
                else
                //  
                02E3: 1@ = car 0@ speed
                if
                    0035:   1@ >= 23@  // (float)
                then
                    Violation_Type = Speed_Limit
                    0085: 25@ = 20@ //   
                end
            end

        if
            08B7:   test Bit_sets bit 1 //     
        then
            9@ = 0
            while 0EA8: get_any_car_no_save_recursive 9@ progress_to 9@ car_to 2@
                02E3: 1@ = car 0@ speed
                if and
                    051D:   car 2@ damaged_by_car 0@
                    8119:   not car 2@ wrecked
                    0EE8: locate_car_distance_to_car 0@ car 2@ radius 8.0
                    1@ > 3.0
                    09CB:   vehicle 0@ colliding_with_vehicle 2@
                then
                    Violation_Type = Car_Collided
                    0085: 25@ = 24@ //   
                    break
                end
            end
        end

        if
            08B7:   test Bit_sets bit 2 //     
        then
            10@ = 0
            while 0EA9: get_any_object_no_save_recursive 10@ progress_to 10@ object_to 3@
                02E3: 1@ = car 0@ speed
                if and
                    0366:   object 3@ damaged
                    0EE7: locate_car_distance_to_object 0@ object 3@ radius 8.0
                    1@ > 1.0
                    0897:   car 0@ collided_with_object 3@
                then
                    Violation_Type = Object_Collided
                    0085: 25@ = 28@ //   
                    break
                end
            end
        end


//   
if or
    Violation_Type == Speed_Limit
    Violation_Type == Car_Collided
    Violation_Type == Object_Collided
then
    if
        856D:   not actor Police_Man defined
    then
        continue
    end


    if or
        08B7:   test Bit_sets bit 3 //  
        08B7:   test Bit_sets bit 4 //  
    then
        if or
            80DF:   not actor Police_Man driving
            08B7:   test Bit_sets bit 4 //  
        then
            010E: set_player $PLAYER_CHAR minimum_wanted_level_to 1
            continue
        end
    end

if
    00DF:   actor Police_Man driving
then

    if
        08B7:   test Bit_sets bit 5 //    
    then
        if
            not 27@ <= 1
        then
            27@ -= 1 //    
        else
            010E: set_player $PLAYER_CHAR minimum_wanted_level_to 2
            0085: 27@ = 11@ //   
            continue
        end
    end

    Police_Car = Actor.CurrentCar(Police_Man)
        if
            047A:   actor Police_Man driving_bike
        then
            1@ = 6.0
        else
            1@ = 8.0
        end
    00AE: set_car Police_Car traffic_behaviour_to 2
    07F8: car Police_Car follow_car 0@ radius 1@
    0397: enable_car Police_Car siren 1
    099E: enable_police_patrols 0
    00AD: set_car Police_Car max_speed_to 500.0
    0006: TIMERB = 0
    0006: TIMERA = 0

    0390: load_txd_dictionary 'cpscr'
    038F: load_texture "speed1" as 1
    038F: load_texture "speed2" as 2
    038F: load_texture "speed3" as 3
    10@ = 0
    wait 50
    
repeat
wait 0
gosub @Check
if
    08B7:   test Bit_sets bit Check_Actor
then
    if
        00DF:   actor Police_Man driving
    then
        if
            08B7:   test Bit_sets bit Check_Player_Car
        then
            Police_Car = Actor.CurrentCar(Police_Man)
            00AE: set_car Police_Car traffic_behaviour_to 2
            if
                047A:   actor Police_Man driving_bike
            then
                1@ = 6.0
            else
                1@ = 8.0
            end
        07F8: car Police_Car follow_car 0@ radius 1@
        gosub @Wav
        if and
            0019:   TIMERA > 7000
            0204:   actor $PLAYER_ACTOR near_car Police_Car radius 20.0 20.0 sphere 0 in_car
        then
            0209: 1@ = random_int_in_ranges 56808 56822
            if or
                1@ == 56808
                1@ == 56811
                1@ == 56815
                1@ == 56817
                1@ == 56820
                1@ == 56821
            then
                03CF: load_wav 1@ as 1
                if
                    03D0:   wav 1 loaded
                then
                    0A16: link_wav 1 to_car Police_Car
                    03D1: play_wav 1
                    0006: TIMERA = 0
                end
            end
        end
        
    if or
        8204:   not actor $PLAYER_ACTOR near_car Police_Car radius 100.0 100.0 sphere 0 in_car
        010F:   player $PLAYER_CHAR wanted_level > 0
        actor.Dead($PLAYER_ACTOR)
        actor.Dead(Police_Man)
        0119:   car Police_Car wrecked
    then
        if
            8119:   not car Police_Car wrecked
        then
            if
                810F:   not player $PLAYER_CHAR wanted_level > 0
            then
                0397: enable_car Police_Car siren 0
            end
            00AF: set_car Police_Car driver_behaviour_to 1
            00AE: set_car Police_Car traffic_behaviour_to 5
        end
        break
    end
    
    // ds:_ZN6CCheat15m_aCheatsActiveE.IDoAsIPlease ; CCheat::m_aCheatsActive
    0A8D: 1@ = read_memory 0x969171 size 4 virtual_protect 0
    if
        1@ == 1 //   . 1 - never wanted
    then
        0397: enable_car Police_Car siren 0
        00AF: set_car Police_Car driver_behaviour_to 1
        00AE: set_car Police_Car traffic_behaviour_to 5
        break
    end

    //    
    03F0: enable_text_draw 1
    03E3: set_texture_to_be_drawn_antialiased 1
    038D: draw_texture Violation_Type position 13@ 14@ scale 21@ 22@ RGBA 255 255 255 255
        
    //     
    if
        08B7:   test Bit_sets bit 5 //    
    then
        //    ,    
        081C: draw_text_outline 1 RGBA 0 0 0 255
        gosub @Font
        gosub @Size
        0348: enable_text_draw_proportional 1
        0342: set_text_draw_centered 1
        045B: draw_text_2numbers 29@ 30@ GXT 'copcar6' numbers 25@ 27@  // ~1~:~1~
    else
        081C: draw_text_outline 1 RGBA 0 0 0 255
        gosub @Font
        gosub @Size
        0348: enable_text_draw_proportional 1
        0342: set_text_draw_centered 1
        045A: draw_text_1number 29@ 30@ GXT 'copcar3' number 25@  // ALL RACES WON!~n~~w~$~1~
    end

    //     
    if
        8204:   not actor $PLAYER_ACTOR near_car Police_Car radius 20.0 20.0 sphere 0 in_car
    then
        04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
        00A7: car Police_Car drive_to 1@ 2@ 3@
        088B: set_car Police_Car form_drag_multiplier_to 1.0
        04C4: store_coords_to 1@ 2@ 3@ from_actor Police_Man with_offset 0.0 50.0 0.0
        02E3: 3@ = car Police_Car speed
        if and
            3@ > 15.0
            01AD:   car 0@ sphere 0 near_point 1@ 2@ radius 30.0 80.0
        then
            02E3: 2@ = car Police_Car speed
            02E3: 1@ = car 0@ speed
            0063: 2@ -= 1@  // (float)
            0174: 1@ = car 0@ Z_angle
            0174: 3@ = car Police_Car Z_angle
            0063: 1@ -= 3@  // (float)
            if and
                not is_car_really_in_air Police_Car
                not 2@ > 10.0
                1@ < 10.0
                1@ > -10.0
            then
                00A7: car Police_Car drive_to 1@ 2@ 3@
                02E3: 1@ = car Police_Car speed
                1@ += 15.0
                04BA: set_car Police_Car speed_to 1@
                088B: set_car Police_Car form_drag_multiplier_to 1.0
            end
        end
    end

    //     ,  2
    if and
        01C1:   car 0@ stopped
        01C1:   car Police_Car stopped
        0204:   actor $PLAYER_ACTOR near_car Police_Car radius 10.0 10.0 sphere 0 in_car
    then
        if
            0019:   TIMERA > 3000
        then
            0006: TIMERA = 0
            continue
        end
        if
            0019:   TIMERA > 2000
        then
            Violation_Type = Stopped_car
            break
        end
    else
        //       
        if
            0019:   TIMERB > 100
        then
            10@ += 1
            005A: 25@ += 31@  //   
            0006: TIMERB = 0
        end

        //    
        if
            10@ >= Time_Message
        then
            1@ = Time_Limit
            0062: 1@ -= 10@  // (int)
            1@ /= 10
            01E5: show_text_1number_highpriority GXT 'copcar5' number 1@ time 500 flag 1  // ~s~You need $~1~ to compete.
        end
        
        //   ,   
        if or
            10@ >= Time_Limit
            0E4A: is_char_exiting_any_car $PLAYER_ACTOR
        then
            010E: set_player $PLAYER_CHAR minimum_wanted_level_to 2
            break
        end
        
    end
        //     
        else
            00AF: set_car Police_Car driver_behaviour_to 1
            00AE: set_car Police_Car traffic_behaviour_to 5
            break
        end
    //    
    else
        break
    end
//    
else
    break
end
until not player.Defined(0)

// ,    ,    @exit.    Violation_Type  
if
    Violation_Type == Stopped_car
then

    //    
    046C: Police_Man = car Police_Car driver
    04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset -1.5 0.0 0.0
    0172: 7@ = actor $PLAYER_ACTOR Z_angle
    000B: 7@ += 270.0
    0615: define_AS_pack_begin 10@
    05CD: AS_actor -1 exit_car Police_Car
    07CD: AS_actor -1 walk_to 1@ 2@ 3@ stop_with_angle 7@ within_radius 0.0
    0616: define_AS_pack_end 10@
    0618: assign_actor Police_Man to_AS_pack 10@
    061B: remove_references_to_AS_pack 10@
        
        repeat
        wait 0
        04ED: load_animation  "copscar"
        until 04EE:   animation "copscar" loaded

        gosub @Wav
        
    //   ,        
    if
        8431: not car Police_Car passenger_seat_free 0
    then
        0432: 9@ = get_actor_handle_from_car Police_Car passenger_seat 0
        0615: define_AS_pack_begin 10@
        05CD: AS_actor -1 exit_car Police_Car
        0812: AS_actor -1 perform_animation "policemod2" IFP "copscar" framedelta 4.0 loopA 1 lockX 1 lockY 0 lockF 1 time -1
        0616: define_AS_pack_end 10@
        0618: assign_actor 9@ to_AS_pack 10@
        061B: remove_references_to_AS_pack 10@
    end

timera = 0
repeat
wait 0
gosub @Check
if and
    08B7:   test Bit_sets bit Check_Actor
    08B7:   test Bit_sets bit Check_Car
    08B7:   test Bit_sets bit Check_Player_Car
then
    
//      ,   
if
    Violation_Type == Stopped_car
then
    if
        00DB:   actor $PLAYER_ACTOR in_car 0@
    then
        00BC: show_text_highpriority GXT 'copcar4' time 100 flag 1  // ~s~Come back between 9:00 and 17:00.
        04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset -1.5 0.0 0.0
        if
            timera > 5000
        then
            0172: 7@ = actor $PLAYER_ACTOR Z_angle
            000B: 7@ += 270.0
            07CD: AS_actor Police_Man walk_to 1@ 2@ 3@ stop_with_angle 7@ within_radius 0.0
            timera = 0
        end
        if
            00EC:   actor Police_Man sphere 0 near_point 1@ 2@ radius 0.5 0.5
        then
            0639: AS_actor Police_Man rotate_to_actor $PLAYER_ACTOR
            wait 0
            0209: 1@ = random_int_in_ranges 1 4
            if 1@ == 1
            then 0812: AS_actor Police_Man perform_animation "policemod1" IFP "copscar" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1
            end
            if 1@ == 2
            then 0812: AS_actor Police_Man perform_animation "policemod2" IFP "copscar" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1
            end
            if 1@ == 3
            then 0812: AS_actor Police_Man perform_animation "policemod3" IFP "copscar" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1
            end
            wait 300
            Violation_Type = Pressed_Key_step
            0006: TIMERA = 0
            continue
        end
    end
end

//       
if
    Violation_Type == Pressed_Key_step
then
    if
        010A:   player $PLAYER_CHAR money > 25@
    then
        01E5: show_text_1number_highpriority GXT 'copcar1' number 25@ time 100 flag 1  // ~s~You need $~1~ to compete.
    else
        01E5: show_text_1number_highpriority GXT 'copcar2' number 25@ time 100 flag 1  // ~s~You need $~1~ to compete.
    end
    if
        0A4B:   controls_set_to_joystick
    then
        if
            00E1:   player 0 pressed_key 19@
        then
            Violation_Type = Actor_pay
        end
    else
        if
            is_key_pressed 17@
        then
            Violation_Type = Actor_pay
        end
    end
end

//   ,      ,     
if
    Violation_Type == Actor_pay
then
    if
        010A:   player $PLAYER_CHAR money > 25@
    then
        0006: TIMERA = 0
        06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 1
        0812: AS_actor Police_Man perform_animation "pay2" IFP "copscar" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time 3500
        0812: AS_actor $PLAYER_ACTOR perform_animation "pay_player" IFP "copscar" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1
        0D33: set_car 0@ door 10 window_state 1  //  
        Violation_Type = Actor_pay_step_2
        wait 100
        continue
    else
        gosub @Arrest
        break
    end
end

//    
if
    Violation_Type == Actor_pay_step_2
then
    if
        0019:   TIMERA > 2700
    then
        model.Load(1212)
        038B: load_requested_models
        25@ *= -1
        Player.Money($PLAYER_CHAR) += 25@
        25@ *= -1
        0E2E: create_render_object_to_char_bone Police_Man model 1212 bone 34 offset 0.08 0.05 -0.04 rotation 0 0 0 store_to 15@
        0E30: set_render_object_auto_hide 15@ dead 1 weapon 0 car 1
        model.Destroy(1212)
        Violation_Type = Actor_pay_step_3
    end
end

//          
if
    Violation_Type == Actor_pay_step_3
then
    if
        not Actor.Animation(Police_Man) == "pay2"
    then
        0E2F: delete_render_object 15@
        06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 0
        0D33: set_car 0@ door 10 window_state 0  //  
        0397: enable_car Police_Car siren 0
        05D2: AS_actor Police_Man run_to_and_hijack_car Police_Car max_search_radius 30.0 traffic_behavior 5
        00AF: set_car Police_Car driver_behaviour_to 1
        00AE: set_car Police_Car traffic_behaviour_to 5
        Violation_Type = Back_to_car
        0085: 27@ = 11@ //   
        
        if
            056D:   actor 9@ defined
        then
            0615: define_AS_pack_begin 10@
            05CA: AS_actor -1 enter_car 6@ passenger_seat 0 time 10000
            0616: define_AS_pack_end 10@
            0618: assign_actor 9@ to_AS_pack 10@
            061B: remove_references_to_AS_pack 10@
        end
        
        break
    end
end

// ,   ,   ,   
if
    00DB:   actor $PLAYER_ACTOR in_car 0@
then
    //        
    if
        0A4B:   controls_set_to_joystick
    then
        // 
        2@ = 4
        3@ = 6
    else
        // 
        2@ = 5
        3@ = 7
    end
        02E3: 1@ = car 0@ speed
        if or
            0E4A: is_char_exiting_any_car $PLAYER_ACTOR
            00E1:   player 0 pressed_key 2@
            00E1:   player 0 pressed_key 3@
            1@ > 3.0
        then
            010E: set_player $PLAYER_CHAR minimum_wanted_level_to 2
            break
        end
else
    010E: set_player $PLAYER_CHAR minimum_wanted_level_to 2
    break
end

//    
if and
    Violation_Type == Pressed_Key_step
    0019:   TIMERA > 5000
then
    gosub @Arrest
    break
end

//     
if
    8104:   not actor $PLAYER_ACTOR near_actor Police_Man radius 15.0 15.0 5.0 sphere 0
then
    break
end

//       
else
    break
end
until not player.Defined(0)
end

gosub @Wav
    gosub @Exit
                end
                    end
                        end
                    end
                end
            end
        end
    end
end

:Check
08C3: clear Bit_sets bit Check_Actor
08C3: clear Bit_sets bit Check_Car
08C3: clear Bit_sets bit Check_Player_Car
if
    056D:   actor Police_Man defined
then
    if
        8118:   not actor Police_Man dead
    then
        08BD: set Bit_sets bit Check_Actor
    end
end
if
    056E:   car Police_Car defined
then
    if
        8119:   not car Police_Car wrecked
    then
        08BD: set Bit_sets bit Check_Car
    end
end
if
    056E:   car 0@ defined
then
    if and
        00DB:   actor $PLAYER_ACTOR in_car 0@
        8119:   not car 0@ wrecked
    then
        08BD: set Bit_sets bit Check_Player_Car
    end
end
return


:Wav
if
    03D0:   wav 1 loaded
then
    if
        03D2:   wav 1 ended
    then
        040D: unload_wav 1
    end
end
return

:Font
if 08B7:   test Bit_sets bit Text_font_0
then 0349: set_text_draw_font 0
end
if 08B7:   test Bit_sets bit Text_font_1
then 0349: set_text_draw_font 1
end
if 08B7:   test Bit_sets bit Text_font_2
then 0349: set_text_draw_font 2
end
if 08B7:   test Bit_sets bit Text_font_3
then 0349: set_text_draw_font 3
end
return

:Size
if 08B7:   test Bit_sets bit Text_Size_1
then 033F: set_text_draw_letter_size 0.4 0.8
end
if 08B7:   test Bit_sets bit Text_Size_2
then 033F: set_text_draw_letter_size 0.5 1.0
end
if 08B7:   test Bit_sets bit Text_Size_3
then 033F: set_text_draw_letter_size 0.6 1.2
end
if 08B7:   test Bit_sets bit Text_Size_4
then 033F: set_text_draw_letter_size 0.7 1.4
end
return

:Arrest
model.Load(#COLT45)
038B: load_requested_models
01B2: give_actor Police_Man weapon 22 ammo 999 // Load the weapon model before using this
0EAA: set_char_arrested $PLAYER_ACTOR //  
0635: AS_actor Police_Man aim_at_actor $PLAYER_ACTOR -1 ms
model.Destroy(#COLT45)
wait 5000
return


:Exit
099E: enable_police_patrols 1
if
    04EE:   animation "copscar" loaded
then
    04EF: release_animation "copscar"
end
if
    056D:   actor Police_Man defined
then
    if and
        Violation_Type >= Stopped_car
        Violation_Type < Back_to_car
        not actor.Dead(Police_Man)
    then
        0792: disembark_instantly_actor Police_Man
    end
end
if
    056D:   actor 9@ defined
then
    if and
        Violation_Type >= Stopped_car
        Violation_Type < Back_to_car
        not actor.Dead(Police_Man)
    then
        0792: disembark_instantly_actor 9@
    end
end
wait 100
0391: release_textures
return